﻿<!--revision $Id$-->
<Window x:Class="OpenWPFChart.Helpers.RangeAreaItemsDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:parts="clr-namespace:OpenWPFChart.Parts;assembly=OpenWPFChart.Parts"
	Name="theDialog"
	Style="{DynamicResource dialogWindow}"
    Title="RangeArea Items" 
	MinWidth="150" MinHeight="100" WindowStartupLocation="CenterOwner"
	FocusManager.FocusedElement="{Binding ElementName=lbxItems}"
	>

	<Window.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="../DialogStyle.xaml"/>
			</ResourceDictionary.MergedDictionaries>

			<DataTemplate DataType="{x:Type parts:RangeAreaDataView}">
				<TextBlock>
					<TextBlock Text="{Binding Path=ItemDataView1.ItemData.ItemName}"/>
					<TextBlock Text=" + "/>
					<TextBlock Text="{Binding Path=ItemDataView2.ItemData.ItemName}"/>
				</TextBlock>
			</DataTemplate>
			
			<DataTemplate DataType="{x:Type parts:ItemDataView}">
				<TextBlock Text="{Binding Path=ItemData.ItemName}"/>
			</DataTemplate>
		</ResourceDictionary>
	</Window.Resources>

	<DockPanel>
		<!-- Dialog buttons row -->
		<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" 
					HorizontalAlignment="Right" VerticalAlignment="Bottom">
			<Button Name="btnOK" Click="btnOK_Click"  Style="{StaticResource dialogButton}" IsDefault="True" IsEnabled="False">OK</Button>
			<Button Style="{StaticResource dialogButton}" IsCancel="True">Cancel</Button>
		</StackPanel>
		
		<Grid>
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto"/>
				<RowDefinition/>
			</Grid.RowDefinitions>
			<Grid.ColumnDefinitions>
				<ColumnDefinition/>
				<ColumnDefinition Width="Auto"/>
				<ColumnDefinition/>
			</Grid.ColumnDefinitions>
			
			<!--ItemDataView list-->
			<TextBlock>Items</TextBlock>
			<ListBox Grid.Row="1" Name="lbxItems"
				ItemsSource="{Binding Path=ItemsCollection}"
				SelectionMode="Extended"	 
				SelectionChanged="lbxSelectionChanged" />
			
			<!--Create/Delete RangeArea Buttons-->
			<StackPanel Grid.Column="1" Grid.RowSpan="2">
				<Button Command="{Binding Path=CreateRangeAreaCommand}"
						CommandParameter="{Binding ElementName=lbxItems, Path=SelectedItems}"
						ToolTip="Click to create new RangeArea">
					&gt;
				</Button>
				<Button VerticalContentAlignment="Center"
					Command="{Binding Path=DeleteRangeAreaCommand}"
					CommandParameter="{Binding ElementName=lbxRangeAreas, Path=SelectedItems}"
						ToolTip="Click to delete RangeAreas selected">
					<TextBlock Foreground="Red" FontWeight="Bold">x</TextBlock>
				</Button>
			</StackPanel>
			
			<!--RangeAreaDataView column-->
			<TextBlock Grid.Column="2">Range Areas</TextBlock>
			<Grid Grid.Row="1" Grid.Column="2">
				<Grid.RowDefinitions>
					<RowDefinition MinHeight="40"/>
					<RowDefinition Height="Auto"/>
				</Grid.RowDefinitions>
				
				<!--RangeAreaDataView list-->
				<ListBox Name="lbxRangeAreas"
					ItemsSource="{Binding Path=RangeAreasCollection}"
					SelectionMode="Extended"	 
					SelectionChanged="lbxSelectionChanged" />
				<!--Area Fill-->
				<GroupBox Grid.Row="1" Header="Area Fill">
					<Button 
						Command="{Binding Path=ChooseRangeAreaColorCommand}"
						CommandParameter="{Binding ElementName=lbxRangeAreas, Path=SelectedItems}"
						ToolTip="Click to select RangeArea Color">
						<Rectangle Width="50" Height="17" 
								   Fill="{Binding ElementName=lbxRangeAreas, Path=SelectedItem.AreaBrush}"/>
					</Button>
				</GroupBox>
			</Grid>
		</Grid>
	</DockPanel>
</Window>
